/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.wholeconsulting.pacc.tests.persistance.database;

import ar.com.wholeconsulting.pacc.model.Fluido;
import ar.com.wholeconsulting.pacc.persistance.JPASession;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author pable
 */
public class FluidoImporter extends Importer {

    private static final String QUERY = "select * from fluidos";

    public FluidoImporter(Connection con) {
        super(con);
    }

    @Override
    protected void importData(ResultSet rs) {
        Fluido fluido = new Fluido();
        try {
            fluido.setNombre(rs.getString(2));
            fluido.setMasaMolecular(rs.getDouble(3));
            fluido.setSgg(rs.getDouble(4));
            fluido.setCoeficienteIncompresibilidad(rs.getDouble(5));
            fluido.setK(rs.getDouble(6));
            fluido.setPuntoDeInflamacion(rs.getInt(7));
            fluido.setPuntoDeEbullicion(rs.getInt(8));
            fluido.setDensidad(rs.getDouble(9));
            fluido.setSgl(rs.getDouble(10));
            fluido.setCalorLatenteDeVaporizacion(rs.getInt(11));
            JPASession.getInstance().getManager().persist(fluido);
        } catch (SQLException ex) {
            Logger.getLogger(FluidoImporter.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void importaData() {
        try {
            queryData(QUERY);
        } catch (SQLException ex) {
            Logger.getLogger(FluidoImporter.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
